package com.java.payweb.service;

import com.java.common.vo.R;
import com.java.pay.entity.PaymentInfo;
import com.java.pay.entity.PaymentType;
import com.java.payweb.feign.PayFeign;
import com.java.payweb.service.impl.UnPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author jiangli
 * @since 2019/12/15 20:14
 */
@Service
public class PayService {
	@Autowired
	private PayFeign paymentTypeFeign;
	@Autowired
	private UnPayService unPayService;

	public String pay(PaymentInfo paymentInfo) {
		Long typeId = paymentInfo.getTypeId();
		PaymentType paymentType = paymentTypeFeign.getPaymentTypeById(typeId);
		if (paymentType == null) {
			return null;
		}
		String typeName = paymentType.getTypeName();
		PayAdaptService payAdaptService = null;
		switch (typeName) {
			case "unPay":
				payAdaptService = unPayService;
				break;
			default:
				break;
		}
		return payAdaptService.pay(paymentInfo, paymentType);
	}
}
